package com.sinodata.bsm.cicp.collector.was6;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import org.apache.log4j.Logger;

import com.sinodata.bsm.cicp.exception.CollectorException;

/**
 * 
 * <p>
 * Description: 
 * </p>
 *
 * @author liulibo
 * @version 1.0

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2012-12-26 AM 10:02:04   liulibo        1.0         To create
 * </p>
 *
 * @since 
 * @see
 */
public class PMIClient {

    private static final Logger logger = Logger.getLogger(PMIClient.class);

    public String getModuleXml(String urlStr, String moduleName) throws CollectorException {
        URL url = null;
        HttpURLConnection connection = null;
        try {
            url = new URL(urlStr + "?module=" + moduleName);
            connection = (HttpURLConnection) url.openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
        } catch (Exception e) {
            logger.error("failed to getModuleXml", e);
            throw new CollectorException(e);
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }
        return null;
    }

    public static void main(String[] args) {

    }
}
